package com.qf.agro.web.controller.sys;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.qf.agro.common.sys.ResultInfo;
import com.qf.agro.pojo.sys.Company;
import com.qf.agro.service.sys.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 六六六
 * @create: 2023-06-29 16:37
 **/
@RestController
@RequestMapping("/company")
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    @GetMapping(value = "/page",name = "分页查询列表")
    public ResultInfo page(@RequestParam(defaultValue = "1",value = "page") Integer pageNum,
                           @RequestParam(defaultValue = "5") Integer pageSize,
                           String name){
        Page<Company> page = companyService.findPage(pageNum, pageSize, name);
        return ResultInfo.success(page);
    }


    @PostMapping
    public ResultInfo insert(@RequestBody Company company){
        companyService.insert(company);
        return  ResultInfo.success("添加成功");
    }


    @PutMapping
    public  ResultInfo update(@RequestBody Company company){
        companyService.update(company);
        return  ResultInfo.success("修改成功");
    }

    @DeleteMapping
    public ResultInfo delete(String id){
        companyService.delete(id);
        return  ResultInfo.success("删除成功");
    }
}
